from selenium.webdriver.common.by import By

from part import BarFace
from Driver.Driver import MDriver
class SendPost:
    driver=''
    def __init__(self):
        self.driver=MDriver.driver
    # 进入编辑界面
    def Come(self):
        BarFace.BarFace().Come()
        self.driver.find_element(By.CSS_SELECTOR,"#bit-forum-content > div.page-header.d-print-none > div > div > div.col-auto.ms-auto.d-print-none > div > a.btn.btn-primary.d-none.d-sm-inline-block.article_post").click()
        self.driver.execute_script("document.body.style.zoom='0.5'")
    # 方便写代码
    def QFind(self,name):
        self.driver.find_element(By.CSS_SELECTOR,name)
    # 界面元素
    def SendPostFace(self):
        # 查找板块选择框
        self.QFind("#article_post_borad")
        # 查找标题输入框
        self.QFind("#article_post_title")
        # 查找写作编辑器
        self.QFind("#article_post_title")
        # 查找发布按钮
        self.QFind("#article_post_submit")
        # 查找“发新帖”文字
        self.QFind("#article_post_submit")

    # 选择Java板块
    def SendPostChageBlock(self):
        self.driver.find_element(By.CSS_SELECTOR,"#article_post_borad").click()
        self.driver.find_element(By.CSS_SELECTOR,"#article_post_borad > option:nth-child(1)").click()
    # 输入标题
    def SendPostTitle(self,title):
        self.driver.find_element(By.CSS_SELECTOR,"#article_post_title").send_keys(title)
    # 输入内容
    def SendPostWord(self):
        self.driver.find_element(By.CSS_SELECTOR,"#edit-article > div.editormd-toolbar > div > ul > li:nth-child(12) > a > i").click()
    # 点击发布
    def SendPostPut(self):
        self.driver.find_element(By.CSS_SELECTOR,"#article_post_submit").click()
    # 清空标题
    def SendPostDeleteTitle(self):
        self.driver.find_element(By.CSS_SELECTOR,"#article_post_title").clear()
    # 清空标题
    def SendPostDeleteWord(self):
        self.driver.find_element(By.CSS_SELECTOR,"#article_post_title").clear()

